import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DefectiveItemVO, DefectiveItemForm, DefectiveItemQuery } from '@/api/base/defectiveItem/types';

/**
 * 查询不良品项列表
 * @param query
 * @returns {*}
 */
export const listDefectiveItem = (query?: DefectiveItemQuery): AxiosPromise<DefectiveItemVO[]> => {
  return request({
    url: '/base/defectiveItem/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取产线管理列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: DefectiveItemForm): AxiosPromise<DefectiveItemForm[]> => {
  return request({
    url: '/base/defectiveItem/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询不良品项详细
 * @param id
 */
export const getDefectiveItem = (id: string | number): AxiosPromise<DefectiveItemVO> => {
  return request({
    url: '/base/defectiveItem/' + id,
    method: 'get'
  });
};

/**
 * 新增不良品项
 * @param data
 */
export const addDefectiveItem = (data: DefectiveItemForm) => {
  return request({
    url: '/base/defectiveItem',
    method: 'post',
    data: data
  });
};

/**
 * 修改不良品项
 * @param data
 */
export const updateDefectiveItem = (data: DefectiveItemForm) => {
  return request({
    url: '/base/defectiveItem',
    method: 'put',
    data: data
  });
};

/**
 * 删除不良品项
 * @param id
 */
export const delDefectiveItem = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/defectiveItem/' + id,
    method: 'delete'
  });
};
